﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>配置管理平台</title>
    <link href="lib/layui/css/layui.css" rel="stylesheet" />
    <link href="x-admin/css/font.css" rel="stylesheet" />
    <link href="x-admin/css/xadmin.css" rel="stylesheet" />
    <script src="lib/signalr/signalr.js"></script>
    <script src="lib/layui/layui.js"></script>
    <script src="lib/signalr/menutree.js"></script>
</head>
<body style="background-color:#eeeeee;">
    <div>
        <div class="layui-fluid" style="padding:0;">
            <div class="layui-row layui-col-space15">
                <!--配置文件概况-->
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            配置文件概况
                        </div>
                        <div class="layui-card-body">
                            <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog">
                                <li class="layui-col-md2 layui-col-xs6">
                                    <a href="javascript:;" class="x-admin-backlog-body">
                                        <h3>总共配置文件数</h3>
                                        <p>
                                            <cite id="totalnum"></cite>
                                        </p>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs6">
                                    <a href="javascript:;" class="x-admin-backlog-body">
                                        <h3>当日新增文件数</h3>
                                        <p>
                                            <cite id="todaynum"></cite>
                                        </p>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs6">
                                    <a href="javascript:;" class="x-admin-backlog-body">
                                        <h3>流程配置文件数</h3>
                                        <p>
                                            <cite id="processnum"></cite>
                                        </p>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs6">
                                    <a href="javascript:;" class="x-admin-backlog-body">
                                        <h3>模块配置文件数</h3>
                                        <p>
                                            <cite id="moudlenum"></cite>
                                        </p>
                                    </a>
                                </li>
                                <li class="layui-col-md2 layui-col-xs6">
                                    <a href="javascript:;" class="x-admin-backlog-body">
                                        <h3>机器学习配置文件数</h3>
                                        <p>
                                            <cite id="mlnum"></cite>
                                        </p>
                                    </a>
                                </li>

                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        layui.$(function () {
            layui.use(['element', 'layer', 'util'], function () {
                var element = layui.element;
                var connection = new signalR.HubConnectionBuilder().withUrl(localStorage.getItem('hosttingaddr') + "/signalHub").build();
                connection.start().catch(err => console.error(err.toString()));
                connection.on("ReceiveMessage", function (data) {
                    if (data != null && data != "") {
                        var obj = JSON.parse(data);
                        if (obj != null && obj.desk != null) {
                            var desk = obj.desk;
                            layui.jquery('#totalnum').text(desk.totalfilesnum);
                            layui.jquery('#todaynum').text(desk.todayaddfiles);
                            layui.jquery('#processnum').text(desk.processcfgfilesnum);
                            layui.jquery('#moudlenum').text(desk.modulecfgfilenum);
                            layui.jquery('#mlnum').text(desk.mlcfigfilenum);
                            var navs = obj.menus;
                            loadMenu(navs);
                            layui.element.init();
                            location.reload();
                        }
                    }
                });
                // 读取数据
                layui.jquery.ajax({
                    url: localStorage.getItem('hosttingaddr') + "/api/main/welcome",
                    method: "Get",
                    success: function (res) {
                        layui.jquery('#totalnum').text(res.totalfilesnum);
                        layui.jquery('#todaynum').text(res.todayaddfiles);
                        layui.jquery('#processnum').text(res.processcfgfilesnum);
                        layui.jquery('#moudlenum').text(res.modulecfgfilenum);
                        layui.jquery('#mlnum').text(res.mlcfigfilenum);
                    }
                });
            });
        });
    </script>
</body>
</html>